<template>
  <el-dialog
    :title="title"
    :visible.sync="dialogVisible"
    class="dialog-component"
    append-to-body
    width="360px"
    top="35%"
    :show-close="false"
    @close="close"
  >
    <div class="dialog-body">
      <el-input v-model="text"></el-input>
    </div>
    <div slot="footer" class="counter-dialog-footer">
      <el-button @click="close">取消</el-button>
      <el-button type="primary" @click="confirmFn">确定</el-button>
    </div>
  </el-dialog>
</template>

<script lang="ts">
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
@Component({
  components: {},
})
export default class DialogComponent extends Vue {
  title = "提示";
  text = "";
  private dialogVisible = true;
  callback: any = null; // 声明变量后，在 dialog.ts 中重新复制
  close() {
    this.dialogVisible = false;
    this.callback({ action: "cancel", data: null });
  }
  confirmFn() {
    this.callback({ action: "confirm", data: this.text });
    this.dialogVisible = false;
  }
}
</script>

<style lang="scss">
.dialog-component {
  text-align: left;
  padding: 20px;
  padding-top: 15vh;
  .dialog-body {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
</style>
